package nc.bs.capub.func;

import java.util.Stack;

import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.PostfixMathCommand;


public class IIFFunc extends PostfixMathCommand {

	/**
	 * 
	 */
	public IIFFunc() {
		numberOfParameters = 3;
	}
	
	
	/* (non-Javadoc)
	 * @see org.nfunk.jep.function.PostfixMathCommandI#run(java.util.Stack)
	 */
	@SuppressWarnings("unchecked")
	public void run(Stack st) throws ParseException {
		checkStack(st);
		
		Object v2 = st.pop();
		Object v1 = st.pop();;
		double b = ((Double)st.pop()).doubleValue();
		
		if(b>0.5d) {
			st.push(v1);
		} else {
			st.push(v2);
		}
	}
}
